home *** CD-ROM | disk | FTP | other *** search
- Path: news.uni-stuttgart.de!news
- From: Markus Heller <Markus.Heller@studbox.uni-stuttgart.de>
- Newsgroups: comp.lang.c
- Subject: char* still alive after free ???
- Date: Mon, 15 Apr 1996 17:23:22 +0200
- Organization: Comp.Center (RUS), U of Stuttgart, FRG
- Message-ID: <317269EA.11BB93C2@studbox.uni-stuttgart.de>
- NNTP-Posting-Host: rusxppp176.rus.uni-stuttgart.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4CALDERA (X11; I; Linux 1.2.13 i486)
-
- Hi,
-
- I have a global variable :
-
- char *text=NULL;
-
- I want to use it to store different "strings" (at diffreent times).
- E.g., if I want to sore 10 characters in text, I do a
- text=(char *) malloc(10*sizeof(char));
- When I want to use text to store 3 other characters, I first do a
- free(text); text=NULL; and finally a
- text=(char *) malloc(3*sizeof(char));
- But to my surprise there are still the 4thh to 10th charcter of
- text contained before the free(text)/malloc... ???
- This happens under linux, but why ?
- (what I want to to is to get filenames from the user and then open those
- files by a function to which I pass the file name..)
-
- Markus
-